<!DOCTYPE html>
<html>
	{include file="public/_header" /}
	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-body ">
							<form class="layui-form" action="">
								<div class="layui-form-item">
									<label class="layui-form-label">字段名称</label>
									<div class="layui-input-inline">
										<input type="text" name="ename" value="{$rest['ename']}" disabled="disabled" lay-verify="required" autocomplete="off" placeholder="字段名称" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">编辑的时候不可以更改</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">字段标题</label>
									<div class="layui-input-inline">
										<input type="text" name="cname"  value="{$rest['cname']}"  lay-verify="required" autocomplete="off" placeholder="字段标题" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">字段标题</div>
								</div>

								<div class="layui-form-item">
									<label class="layui-form-label">字段类型</label>
									<div class="layui-input-inline">
										<select name="type" lay-verify="required" lay-filter="field_type" disabled="disabled">
											<option value=""></option>
											{foreach $type as $key=>$vo }
											<option value="{$vo.id}" {if ( $rest['type'] == $vo.id) } selected="selected" {/if}>{$vo.title} | {$vo.name}</option>
											{/foreach}
										</select>
									</div>
									<div class="layui-form-mid layui-word-aux">选取字段类型</div>
								</div>
								{if ( $rest['value']) }
								<div class="layui-form-item">
									<label class="layui-form-label">选项</label>
										<div class="layui-input-inline">
											<textarea placeholder="请输入选项" lay-verify="required" name="value" class="layui-textarea">{$rest['value']}</textarea>
										</div>
										<div class="layui-form-mid layui-word-aux">例:头条,1|推荐,2|置顶,3</div>
								</div>
								{/if}
								<div class="layui-form-item">
									<label class="layui-form-label">字段提示</label>
									<div class="layui-input-inline">
										<input type="text" name="descript" value="{$rest['descript']}" required lay-verify="required" placeholder="请输入内容" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">字段提示</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">是否必须</label>
									<div class="layui-input-inline">
										<input type="radio" name="validate" value="1" title="是" {if ( $rest['validate'] == 1) } checked {/if}>
										<input type="radio" name="validate" value="2" title="否" {if ( $rest['validate'] == 2) } checked {/if}>
									</div>
									<div class="layui-form-mid layui-word-aux">如果选择是添加信息时必填</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">排序</label>
									<div class="layui-input-inline">
										<input type="number" name="sort" value="{$rest['sort']}" required lay-verify="required" placeholder="排序" autocomplete="off"
										 class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">排序</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-input-block">
										<input type="hidden" name="id" value="{$rest['id']}" />
										<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
									</div>
								</div>
							</form>

						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			$(function() {
				layui.use('form', function() {
					var form = layui.form;
					var $ = layui.jquery;
					//监听提交
					form.on('submit(demo1)', function(obj) {
						var lfc = top.layerFrameConfig;
						var iframeBIndex = lfc.iframeB.layer_index;
						var iframeCIndex = lfc.iframeC.index;
						var tableInfo = lfc.iframeC.info;
						obj.field.model_id = lfc.iframeC.id;
						$.post("{:url('admin/MouldsField/edit')}", obj.field, function(res) {
							if (res.status == 1) {
								layer.msg(res.message, {
									icon: 1,
									time: 300
								}, function() {
									parent.layer.close(iframeCIndex);
									tableInfo.reload()
								});
							} else {
								layer.msg(res.message)
							}
						})
						return false;
					});
				});


			})
		</script>

	</body>
</html>
